package com.boc.langxiang.ui.adapter.me;

import android.content.Context;
import android.widget.ImageView;

import com.boc.langxiang.R;
import com.boc.langxiang.entity.response.ProductBean;
import com.boc.langxiang.manager.PicassoImageLoader;
import com.boc.langxiang.util.StringUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;


public class OrdersDetailRVAdapter extends BaseQuickAdapter<ProductBean> {
    private String mTotalPrice;
    private int mNum;

    public OrdersDetailRVAdapter(Context context, List<ProductBean> data) {
        super(R.layout.item_me_orders_detail, data);
    }

    public void setTotalPrice(String totalPrice) {
        this.mTotalPrice = totalPrice;
    }

    public void setTotalNum(int num) {
        this.mNum = num;
    }

    @Override
    protected void convert(BaseViewHolder helper, ProductBean item) {
        helper.setText(R.id.tv_me_orders_content, StringUtil.isEmpty(item.getTitle()) ? "" : item.getTitle())
                .setText(R.id.tv_me_orders_realsize, StringUtil.isEmpty(item.getSize()) ? "" : item.getSize())
                .setText(R.id.tv_me_orders_price, "¥" + StringUtil.setPrice(item.getPrice()))
                .setText(R.id.tv_me_orders_num, "×" + (StringUtil.isEmpty(item.getNumber()) ? "" : item.getNumber()))
                .setText(R.id.tv_me_orders_totalprice, StringUtil.priceExecute(StringUtil.setPrice(mTotalPrice)))
                .setText(R.id.tv_me_orders_detail_totalnum, "共" + mNum + "件")
                .setVisible(R.id.relayout_me_orders_dwd, helper.getAdapterPosition() == mNum ? true : false);

        PicassoImageLoader.getInstance().displayUrlImage(mContext, item.getPhotourl()
                , (ImageView) helper.getView(R.id.esv_me_orders_img));
    }
}
